package cn.com.infohold.smartcity.api.converter;

import java.io.Serializable;
import java.lang.reflect.Type;

import fr.arnaudguyon.xmltojsonlib.XmlToJson;


/**
 * Created by Mr.Fan on 2017/3/25.
 */

public class XmlConverter extends JsonConverter {

    @Override
    public String[] getContentTypes() {
        return new String[]{"xml"};
    }

    @Override
    public Serializable convert(String data, Type actualType) throws Throwable {
        return super.convert(convertXmlToJson(data), actualType);
    }

    public String convertXmlToJson(String xml) {
        XmlToJson xmlToJson = new XmlToJson.Builder(xml).build();
        return xmlToJson.toString();
    }

}
